package edu.cuit.canary.selection;

import java.util.Scanner;

/**
 * 程序生成两个10以内的随机整数，完成减法运算，确保被减数大于减数
 * 可以使用Math.random()来产生一个0.0---1.0之间的随机double数（不包括1）  [0，1)
 */
public class SubtractionQuiz {
    public static void main(String[] args) {
        int number1 = (int)(Math.random() * 10);
        int number2 = (int)(Math.random() * 10);
        //确保被减数大于减数
        if(number1 < number2){
            int temp = number1;
            number1 = number2;
            number2 = temp;
        }

        System.out.print(number1 + " - " + number2 + " = ");
        Scanner input = new Scanner(System.in);
        int answer = input.nextInt();
        input.close();

        if(number1 - number2 == answer) {
            System.out.println("回答正确");
        } else {
            System.out.println("回答错误，" + number1 + " - " + number2 + " = " + (number1 - number2));
        }
    }
}
